/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package spring;
import java.io.*;
/**
 *
 * @author spring
 */
public class NLPParser {
    public String[] GetStrings(String Filename) {
        String TextLine;
        String Text = "";
        String article[] = null;

        try {
            BufferedReader br = new BufferedReader(new FileReader(Filename));
            while ((TextLine = br.readLine()) != null) { // while loop begins here
                Text += "" + TextLine + ",";
            //System.out.println(thisLine);
            } // end while 

            article = Text.split(",");

        //System.out.println(article.length);

        //for (int i = 0; i < article.length; i++) {
        //    System.out.println(article[i]);
        //}

        } // end try
        catch (IOException e) {
            System.err.println("Error: " + e);
        }

        return article;
    }

    public String GetText(String Filename) {
        String TextLine;
        String Text = "";

        try {
            BufferedReader br = new BufferedReader(new FileReader(Filename));
            while ((TextLine = br.readLine()) != null) { // while loop begins here
                Text += TextLine + " ";
            } // end while 
        } // end try
        catch (IOException e) {
            System.err.println("Error: " + e);
        }

        return Text;
    }

    public String[][] GetStems(String Filname) {
        String Verbs[] = GetStrings(Filname);

        String Verb[][] = new String[Verbs.length][2];
        for (int i = 0; i < Verbs.length; i++) {
            Verb[i] = Verbs[i].split(" ");
        }

        return Verb;
    }

    public void RemoveWord(String InputWord[], String Articles[]) {
        String Text = "";

        for (int i = 0; i < InputWord.length; i++) {
            for (int j = 0; j < Articles.length; j++) {
                if (InputWord[i].equals(Articles[j])) {
                    InputWord[i] = "";
                }
            }
            Text += InputWord[i] + " ";
        }
        InputWord = Text.split(" ");
    }

    public void toStemmer(String InputWord[], String Stems[][]) {
        String Text = "";

        for (int i = 0; i < InputWord.length; i++) {
            for (int j = 0; j < Stems.length; j++) {
                if (InputWord[i].equals(Stems[j][0])) {
                    InputWord[i] = Stems[j][1];
                }
            }
            Text += InputWord[i] + " ";
        }
        InputWord = Text.split(" ");
    }

}
